%!PS-Adobe-3.0
%%Title: DPeye acts for DPMapIt
%%Creator: Mario Huys, building upon the original mapit by George Boyce and others.
%%EndComments

%%BeginSetup

%<Play Setup>
%<+ /$AbsoluteRoundingError .001 /$Pi 3.14159 /$FindFont findfont /$FontEncoding ISOLatin1Encoding>
%<+ /$MapUnitScale $MapDrawingScale /$MapUnitOffsetX 0 /$MapUnitOffsetY 8 /$MapUnitLetterSize 14>
%<+ /$MapNameScale $MapUnitScale /$MapNameOffsetX 0 /$MapNameOffsetY -14 /$MapNameFontSize 14>
%<+ /$MapSupplyScale $MapDrawingScale>
%<+ /$MapNumberScale $MapDrawingScale /$MapNumberSize 14 /$MaxNumberLength 4>
%<+ /$MapDrawingScale 1 /$BorderStrokeColor BorderBlack>
%<+ /$MapImageWidth {$MapImageRight $MapImageLeft sub} /$MapImageHeight {$MapImageTop $MapImageBottom sub}>
%<+ /$PaintScaleFactor 1 /$StrokeUnit k /$FillUnit f>
%<+ /$ArrowLineThickness 1 /$HeadLength 20 /$HalfHeadThickness 5 /$HalfThickness 1>
%<+ /$ArrowBase 0 /$ArrowShaftLength 40 /$ArrowRotate {}>
%<+ /$HalfSlashThickness 5 /$HalfSlashLength 16>
%<+ /$HoldRadius 24 /$MoveRadius 8 /$ConvoyRadius 12 /$BuildRadius 24 /$FadeRadius 16>
%<+ /$BuildRays 16 /$BuildRayFraction {1 3 div} /$BuildRayThickness 6>
%<+ /$FadeSpots 5 /$FadeStartAngle 90 /$FadeSpotRadius 4>
%<+ /$FogWaveLength 12 /$FogWaveRaiseLength 4 /$FogWaveRaiseHeight 3 /$FogWaveThickness 4 /$FogWaveDistance 8>
%<+ /$MoveColor ArrowBlack /$RetreatColor ArrowRed /$BuildColor ArrowWhite /$ProposeColor ArrowWhite /$DiscoverColor ArrowBlue>
%<+ /$WrapCenterXRatio .5 /$WrapCenterYRatio .5 >
%<+ /$WrapCenterX {$MapImageLeft $MapImageWidth $WrapCenterXRatio mul add} /$WrapCenterY {$MapImageBottom $MapImageHeight $WrapCenterYRatio mul add} >
%<+ /$WrapWidthRatio .5 /$WrapHeightRatio .5 >
%<+ /$WrapWidth {$MapImageWidth $WrapWidthRatio mul} /$WrapHeight {$MapImageHeight $WrapHeightRatio mul} >
%<+ /$TextGapLineLength 2 /$SpaceChar < > /$OpenRoundBracketChar <(> /$CloseRoundBracketChar <)> >
%<+ /$OpenBracketChar $OpenRoundBracketChar /$CloseBracketChar $CloseRoundBracketChar>
%<+ /$NameKey /LongName /$BaseNameLength 10 /$NameLength $BaseNameLength>
%<+ /$Show h /$Stringwidth stringwidth /$ShowText $Show /$ShowMoreText $ShowText /$ShowHeading $Show /$ShowTitle $Show>
%<+ /$FrameScale 1>
%<+ /$FrameLeft $MarginWidth /$FrameBottom $MarginHeight>
%<+ /$FrameWidth {$PageWidth $MarginWidth 2 mul sub} /$FrameHeight {$PageHeight $MarginHeight 2 mul sub}>
%<+ /$FontBaseXRatio 0 /$FontBaseYRatio .28>
%<+ /$FixedFontWidthRatio .6 /$FixedFontHeightRatio 1>
%<+ /$VariableFontWidthRatio .5 /$VariableFontHeightRatio 1>
%<+ /$TextFontSize 8>
%<+ /$TextFontBaseXRatio $FontBaseXRatio /$TextFontBaseYRatio $FontBaseYRatio>
%<+ /$TextFontBaseX {$TextFontBaseXRatio $TextFontSize mul} /$TextFontBaseY {$TextFontBaseYRatio $TextFontSize mul}>
%<+ /$TextFontWidthRatio $FixedFontWidthRatio /$TextFontHeightRatio $FixedFontHeightRatio>
%<+ /$TextFontWidth {$TextFontWidthRatio $TextFontSize mul} /$TextFontHeight {$TextFontHeightRatio $TextFontSize mul}>
%<+ /$HeadingFontSize $TextFontSize>
%<+ /$HeadingFontBaseXRatio $FontBaseXRatio /$HeadingFontBaseYRatio $FontBaseYRatio>
%<+ /$HeadingFontBaseX {$HeadingFontBaseXRatio $HeadingFontSize mul} /$HeadingFontBaseY {$HeadingFontBaseYRatio $HeadingFontSize mul}>
%<+ /$HeadingFontWidthRatio $FixedFontWidthRatio /$HeadingFontHeightRatio $FixedFontHeightRatio>
%<+ /$HeadingFontWidth {$HeadingFontWidthRatio $HeadingFontSize mul} /$HeadingFontHeight {$HeadingFontHeightRatio $HeadingFontSize mul}>
%<+ /$GameTitleFontSize {$TextFontSize 3 mul}>
%<+ /$GameTitleFontBaseXRatio $FontBaseXRatio /$GameTitleFontBaseYRatio $FontBaseYRatio>
%<+ /$GameTitleFontBaseX {$GameTitleFontBaseXRatio $GameTitleFontSize mul} /$GameTitleFontBaseY {$GameTitleFontBaseYRatio $GameTitleFontSize mul}>
%<+ /$GameTitleFontWidthRatio $VariableFontWidthRatio /$GameTitleFontHeightRatio $VariableFontHeightRatio>
%<+ /$GameTitleFontWidth {$GameTitleFontWidthRatio $GameTitleFontSize mul} /$GameTitleFontHeight {$GameTitleFontHeightRatio $GameTitleFontSize mul}>
%<+ /$BoardTitle (Diplomacy) /$BoardTitleFontSize {$TextFontSize 3 mul}>
%<+ /$BoardTitleFontBaseXRatio $FontBaseXRatio /$BoardTitleFontBaseYRatio $FontBaseYRatio>
%<+ /$BoardTitleFontBaseX {$BoardTitleFontBaseXRatio $BoardTitleFontSize mul} /$BoardTitleFontBaseY {$BoardTitleFontBaseYRatio $BoardTitleFontSize mul}>
%<+ /$BoardTitleFontWidthRatio $VariableFontWidthRatio /$BoardTitleFontHeightRatio $VariableFontHeightRatio>
%<+ /$BoardTitleFontWidth {$BoardTitleFontWidthRatio $BoardTitleFontSize mul} /$BoardTitleFontHeight {$BoardTitleFontHeightRatio $BoardTitleFontSize mul}>
%<+ /$FrameThickness 4 /$FrameOverlap 0 /$FrameMarginRatio .5 /$FrameMargin {$FrameThickness $FrameMarginRatio mul}>
%<+ /$FrameMarginWidth $FrameMargin /$FrameMarginHeight $FrameMargin>
%<+ /$FrameOuterColor Black /$FrameInnerColor LandBrown>

%<Act Shorthand>
/bd { bind def } bind def
/xd { exch def } bd
/ld { load def } bd
%</Act>

%<Sketch Math>
/ifloor { $AbsoluteRoundingError add floor cvi } bd
/iceiling { $AbsoluteRoundingError sub ceiling cvi } bd

/min {2 copy gt {exch} if pop} bd
/max {2 copy lt {exch} if pop} bd

/secure_atan { 2 copy 0 eq exch 0 eq and { pop pop 0 } { atan } ifelse } bd
/center { 3 2 roll add 2 div 3 1 roll add 2 div exch } bd
%</Sketch>

%<Scene PaintOperators /operator ld /format {name name}>
	/a /arc ld
	/c /curveto ld
	/d /setdash ld
	/f /fill ld
	/h /show ld
	/k /stroke ld
	/l /lineto ld
	/m /moveto ld
	/n /newpath ld
	/o /rotate ld
	/p /closepath ld
	/r /grestore ld
	/s /gsave ld
	/t /translate ld
	/w /setlinewidth ld
	/x /scale ld
	/y /scalefont ld
	/z /setfont ld
%</Scene>

%<Scene GrayColors /operator g /format {name 1}>
/Black 0 g
/White .9 g
/Grey .7 g
/DarkGrey .52 g
%</Scene>

%<Scene MapGrayColors /operator g /format {name 1}>
/BorderBlack .1 g
/MountainGrey .5 g
/IceGrey .9 g
/ArrowBlack 0 g
/ArrowWhite .9 g
%</Scene>

%<Scene RGBColors /operator r /format {name 3}>
/Red 1 0 0 r
/Blue 0 0 1 r
/Mauve 1 0 1 r
/Magenta 1 0 1 r
/Yellow 1 1 0 r
/Green 0 .7 0 r
/Brown .6 .45 .2 r
/Turquoise .2 .7 .7 r
/LightBlue .4 .6 1 r
/DarkGreen 0 .4 0 r
/LightGreen 0 .9 0 r
/Forest 0 .5 0 r
/Teal 0 .6 .6 r
/Tan .6 .6 .2 r
/Cyan 0 1 1 r
/Orange 1 .6 0 r
/Pink .3 0 0 r
/Maroon .8 0 0 r
/DarkRed 1 0 .5 r
/DarkBlue .52 .52 1 r
/Purple .5 0 .5 r
/ForestGreen .25 .5 .5 r
/Lila 1 .5 1 r
/LightOrange 1 .78 .26 r
/UltraGreen 0 .97 0 r
/DarkBrown 1 .52 .14 r
%</Scene>

%<Scene MapRGBColors /operator r /format {name 3}>
/LandBrown .8 .7 .4 r
/SeaBlue .1 .4 .6 r
/ArrowRed 1 0 0 r
/ArrowBlue .529 .808 .922 r
%</Scene>

%<Scene CMYKColors /operator c /format {name 4}>
%</Scene>

%<Scene MapCMYKColors /operator c /format {name 4}>
%</Scene>

%<Act DefineColors>
  {
    currentdict end 3 1 roll [ exch /setgray load ] cvx def begin
  }{
    currentdict end 5 1 roll [ 4 1 roll /setrgbcolor load ] cvx def begin
  }{
    currentdict end 6 1 roll [ 5 1 roll /setcmykcolor load ] cvx def begin
  } bind VisitColors
%</Act>

%<Act AddPower>
  8 dict dup begin 4 1 roll
  load /Contrast xd
  load /Paint xd
  /Letter xd
  end 
  [ /Power 2 index /def load ] cvx bind
  2 index xd
  Powers 3 1 roll put
%</Act>

%<Act DefinePowers>
  { currentdict end 5 1 roll AddPower begin } bind VisitPowers

  % Letter offsets
  MapUnitLetterFont z
  Powers {
    begin
    /Offset [ n 0 0 m Letter true charpath pathbbox
    3 2 roll add -2 div 3 1 roll add -2 div exch ] def
    end pop
  } forall
%</Act>

%<Act InitController>
  /ChangeController false def
%</Act>

%<Act Controls>
  /ChangeController true def
%</Act>

%<Act InsertController>
  dup /Controlled ChangeController put
  ChangeController {
    dup /Outer Power /Paint get put 
    /ChangeController false def
  } if
%</Act>

%<Act GetLetterOffset>
[ exch n 0 0 m true charpath pathbbox
    3 2 roll add -2 div 3 1 roll add -2 div exch ]
%</Act>

%<Sketch FindAndEncodeFont>
  findfont dup length dict begin { 
  	1 index /FID ne {
  	  def
  	} {
  	  pop pop
  	} ifelse
  } forall
  /Encoding $FontEncoding def
  currentdict
  end 1 index exch definefont
%</Sketch>

%<Sketch MapUnitDefinitions>
%%IncludeResource: font Helvetica-Bold
/MapUnitLetterFont /Helvetica-Bold $FindFont $MapUnitLetterSize y def
%</Sketch>

%<Sketch LocateTroop>
  $MapUnitScale dup x
  $MapUnitOffsetX $MapUnitOffsetY t
%</Sketch>

%<Act PaintLetter>
  Offset aload pop m
  MapUnitLetterFont z
  Contrast Letter h
%</Act>

%<Sketch StrokeUnit>
  2 $PaintScaleFactor div w Contrast k
%</Sketch>

%<Sketch StrokeControllableUnit>
  Controlled {
    s 6 $PaintScaleFactor div w Outer k r
  } if
  2 $PaintScaleFactor div w Contrast k
%</Sketch>

%<Act FillUnit>
  Paint f
%</Act>

%<Sketch PaintArmy>
	n 0 0 9 0 360 a p                      % wheel
	$StrokeUnit
	-20 7 m 10 7 l 10 3 l 14 3 l
	14 1 l -16 1 l -16 3 l -20 3 l p       % barrel
	4 2 m 24 -8 l 26 -8 l 18 -8 l -2 2 l   % carriage
	s $StrokeUnit r $FillUnit
	n 0 0 9 0 360 a p                      % wheel
	$FillUnit
%</Sketch>

%<Sketch PaintFleet>
	-26 -7 m -26 -2 l -19 -2 l -19 -1 l    % to bow
	-22 -1 l -22 0 l -15 0 l -15 1 l       % A turret
	-18 1 l -18 2 l -10 2 l -10 0 l        % B turret
	-9 0 l -9 4 l -8 4 l -8 6 l            % conn tower
	-6 6 l -6 5 l -5 5 l -5 9 l            % Infra struct
	-3 9 l -3 14 l -2 14 l -2 9 l          % funnel 1
	0 9 l 0 5 l 1 5 l 1 8 l                % funnel 2
	3 8 l 3 13 l 4 13 l 4 8 l              % mast 2
	6 8 l 6 0 l 8 0 l 8 2 l                % funnel 2
	16 2 l 16 1 l 13 1 l 13 0 l            % C turret
	20 0 l 20 -1 l 17 -1 l 17 -2 l         % D turret
	23 -2 l 23 -3 l 25 -3 l 25 -5 l        % stern
	24 -5 l 24 -7 l p
	s $StrokeUnit r $FillUnit
%</Sketch>

%<Sketch PaintWing>
	s
	0 -6 t
	% Start from the front
	1 24 m
	% Left part of cockpit
	0 24 l -1 19 l -1 15 l
	% Left wing
	-2 13 l -14 4 l -14.5 5.5 l -15 4 l
	-15 -1 l -14 -1 l -14 0 l -4 1 l
	-3 1 l 
	% Tail 
	-2 -5 l -5 -6 l -5 -7 l 5 -7 l
	5 -6 l 2 -5 l 3 1 l 
	% Right wing
	4 1 l 14 0 l 14 -1 l 15 -1 l 
	15 4 l 14.5 5.5 l 14 4 l 2 13 l
	1 15 l 
	% Right part of cockpit
	1 19 l 0 24 l -1 24 l
	p
	s $StrokeUnit r $FillUnit
	r
%</Sketch>

%<Sketch PaintManOfWar /$PaintScaleFactor .5>
	s
	$PaintScaleFactor dup x	-35 -16 t
	12 3 m 12 9 l 9 12 l 6 13 l 6 17 l      % bow
	9 17 l 9 23 l 2 22 l 7 16 l 6 16 l
	1 22 l                                  % bowsprit
	6 27 l 12 37 l 15 45 l                  % front sail
	19 44 l 19 48 l 16 48 l 15 49 l 19 49 l
	19 55 l 20 55 l 20 49 l 24 49 l 23 48 l
	20 48 l 20 44 l                         % front mast
	24 43 l 24 34 l 27 29 l 33 29 l 33 32 l
	25 32 l 28 39 l 31 51 l                 % mid sail left
	35 50 l 35 54 l 30 54 l 29 55 l 35 55 l
	35 63 l 36 63 l 36 56 l 36 55 l 42 55 l
	41 54 l 36 54 l 36 50 l                 % mid mast
	41 49 l 41 32 l 36 32 l 36 29 l 39 29 l
	41 43 l                                 % mid sail right
	45 43 l 45 47 l 41 47 l 41 48 l 45 48 l
	45 55 l 46 55 l 46 48 l 51 48 l 50 47 l
	46 47 l 46 43 l                         % rear mast
	48 43 l 49 28 l 51 28 l 51 31 l 54 33 l
	54 23 l 57 26 l 57 22 l 56 21 l         % rear sail and flag
	56 15 l 59 12 l 59 7 l 57 4 l 55 3 l p  % bow
	s $StrokeUnit r $FillUnit
	r
%</Sketch>

%<Sketch PaintKnight /$PaintScaleFactor .16>
	s
	$PaintScaleFactor dup x	-121 -82 t
	172 3 m
	174 8 l
	179 12 l
	179 25 l
	184 38 l
	177 46 l
	177 54 l
	185 63 l
	195 59 l
	195 52 l
	192 41 l
	198 28 l
	199 37 l
	205 49 l
	206 60 l
	210 69 l
	204 78 l
	203 90 l
	199 93 l
	192 91 l
	181 80 l
	173 86 l
	166 97 l
	161 123 l
	153 133 l
	146 135 l
	144 146 l
	136 153 l
	142 160 l
	154 159 l
	139 169 l
	127 166 l
	127 158 l
	133 150 l
	129 148 l
	129 144 l
	123 141 l
	129 135 l
	132 131 l
	132 126 l
	129 122 l
	121 118 l
	118 129 l
	105 136 l
	107 142 l
	95 137 l
	88 136 l
	82 132 l
	72 127 l
	67 124 l
	70 115 l
	77 111 l
	85 115 l
	92 115 l
	82 106 l
	78 94 l
	78 84 l
	75 78 l
	76 71 l
	56 61 l
	54 55 l
	62 34 l
	74 25 l
	81 25 l
	80 33 l
	77 36 l
	63 47 l
	66 54 l
	79 56 l
	86 39 l
	91 17 l
	84 11 l
	79 3 l
	93 3 l
	94 12 l
	100 18 l
	96 49 l
	111 49 l
	115 42 l
	134 48 l
	142 48 l
	148 36 l
	135 22 l
	130 9 l
	135 5 l
	141 10 l
	140 18 l
	158 31 l
	156 42 l
	170 37 l
	174 23 l
	168 12 l
	162 7 l
	162 3 l
	p
	s $StrokeUnit r	$FillUnit
	r
%</Sketch>

%<Sketch MapNameDefinitions>
%%IncludeResource: font Helvetica-Bold
/MapNameFont /Helvetica-Bold $FindFont $MapNameFontSize y def
%</Sketch>

%<Sketch LocateName>
  $MapNameScale dup x
  $MapNameOffsetX $MapNameOffsetY t
%</Sketch>

%<Act PaintName>
  MapNameFont z
  dup stringwidth pop -2 div 0 neg m h
%</Act>

%<Act DefineSupply>
  currentdict end 4 1 roll [ 3 1 roll ] cvx def begin
%</Act>

%<Sketch LocateSupply>
  $MapSupplyScale dup x
%</Sketch>

%<Act PaintSupply>
  Paint
  n 0 0 4 0 360 a f
%</Act>

%<Act PaintControllableSupply>
  Controlled {
    Outer
    n 0 0 8 0 360 a f
    Contrast
    n 0 0 6 0 360 a f
  } if
  Paint
  n 0 0 4 0 360 a f
%</Act>

%<Sketch LocateArrow>
  3 index 3 index t
  3 2 roll sub 3 1 roll exch sub exch
  2 copy dup mul exch dup mul add sqrt 3 1 roll exch secure_atan
  $MapUnitScale dup x
  $MapUnitOffsetX $MapUnitOffsetY t
  o
  $MapUnitScale div $ArrowBase sub
%</Sketch>

%<Sketch LocateTrailingArrow>
  t
  $MapUnitScale dup x
  $MapUnitOffsetX $MapUnitOffsetY t
  $ArrowRotate $MapUnitLetterSize $ArrowShaftLength add $ArrowBase add neg 0 t
  $ArrowShaftLength
%</Sketch>

%<Sketch ShortenArrowTail>
  % if base of arrow is long enough, shorten it enough
  % to e.g. move arrow start beyond support circle
  dup $MapUnitLetterSize gt {
    $MapUnitLetterSize dup 0 t sub
  }{
    0 t 0
  } ifelse
%</Sketch>

%<Sketch ShortenArrowTip>
  % if base is still too long, shorten it some more
  % to make arrow head touch support circle
  dup $MapUnitLetterSize gt {
    $MapUnitLetterSize sub
  }{
    pop 0
  } ifelse
%</Sketch>

%<Sketch ArrowMoveBase>
  $HeadLength
%</Sketch>

%<Sketch ArrowRetreatBase>
  $HeadLength 2 mul $HalfThickness $HalfHeadThickness div sub
%</Sketch>

%<Sketch TraceOneSidedArrow>
  % draw the arrow head ...
  n
  dup $HalfThickness neg m
  dup $HalfHeadThickness neg l
  dup $HeadLength add 0 l
  dup $HalfHeadThickness l
  $HalfThickness l
  % now the shaft ...
  0 $HalfThickness l
  0 $HalfThickness neg l
  p
%</Sketch>

%<Sketch TraceTwoSidedArrow>
  % draw the arrow head ...
  n
  dup $HalfThickness neg m
  dup $HalfHeadThickness neg l
  dup $HeadLength add 0 l
  dup $HalfHeadThickness l
  $HalfThickness l
  % again the arrow head at the other side ...
  $HeadLength $HalfThickness l
  $HeadLength $HalfHeadThickness l
  0 0 l
  $HeadLength $HalfHeadThickness neg l
  $HeadLength $HalfThickness neg l
  % close
  p
%</Sketch>

%<Sketch TraceSingleArrowHead>
  % draw the arrow head ...
  n
  dup $HalfHeadThickness neg m
  dup $HeadLength add 0 l
  dup $HalfHeadThickness l
  p
%</Sketch>

%<Sketch TraceDoubleArrowHead>
  % draw the double arrow head ...
  n
  dup $HalfHeadThickness neg m
  dup $HeadLength $HalfThickness $HalfHeadThickness div sub add
  dup $HalfThickness neg l
  dup $HalfHeadThickness neg l
  dup $HeadLength add 0 l
  dup $HalfHeadThickness l
  $HalfThickness l
  dup $HalfHeadThickness l
  p
%</Sketch>

%<Sketch TraceShaft>
  n
  dup $HalfThickness neg m
  $HalfThickness l
  0 $HalfThickness l
  0 $HalfThickness neg l
  p
%</Sketch>

%<Sketch TraceLineShaft>
  $HalfThickness 2 mul w
  0 0 m
  0 l
%</Sketch>

%<Play PaintArrowMove>
  $ArrowLineThickness w

  %<Part none/>
      
  k
  % now the shaft ...
  $HalfThickness 2 mul w
  0 0 m
  0 l
  k
%</Play>

%<Sketch ArrowCircleBase>
  1 index sub
%</Sketch>

%<Sketch PaintArrowCircle>
  % draw the circle ...
  $ArrowLineThickness w
  n
  2 copy add 0 4 3 roll 0 360 a
  p k  
  % now the shaft ...
  $HalfThickness 2 mul w
  0 0 m
  0 l
  k
%</Sketch>

%<Sketch TraceSlash>
  n
  $HalfSlashThickness neg $HalfSlashLength sub $HalfSlashLength neg m
  $HalfSlashThickness neg $HalfSlashLength add $HalfSlashLength l
  $HalfSlashThickness $HalfSlashLength add $HalfSlashLength l
  $HalfSlashThickness $HalfSlashLength sub $HalfSlashLength neg l
  p
%</Sketch>

%<Sketch TraceCross>
  n
  $HalfSlashThickness neg $HalfSlashLength sub $HalfSlashLength neg m
  $HalfSlashThickness neg 0 l $HalfSlashThickness neg $HalfSlashLength sub $HalfSlashLength l $HalfSlashThickness $HalfSlashLength sub $HalfSlashLength l 0 $HalfSlashThickness l
  $HalfSlashThickness neg $HalfSlashLength add $HalfSlashLength l
  $HalfSlashThickness $HalfSlashLength add $HalfSlashLength l
  $HalfSlashThickness 0 l $HalfSlashThickness $HalfSlashLength add $HalfSlashLength neg l $HalfSlashThickness neg $HalfSlashLength add $HalfSlashLength neg l 0 $HalfSlashThickness neg l
  $HalfSlashThickness $HalfSlashLength sub $HalfSlashLength neg l
  p
%</Sketch>

%<Sketch PaintBuildCircle>
%<+ /$BuildDashLength {$Pi 2 mul $BuildRadius mul $BuildRays div}>
%<+ /$BuildRayLength {$BuildDashLength $BuildRayFraction mul}>
%<+ /$BuildSpaceLength {$BuildDashLength 1 $BuildRayFraction sub mul}>
%<+ /$BuildDashStart {$BuildRayLength 2 div}>
  $BuildRayThickness w [ $BuildRayLength# $BuildSpaceLength# ] $BuildDashStart# d
  n
  0 0 $BuildRadius 0 360 a
  p k
%</Sketch>

%<Sketch PaintFadeCircle>
  0 1 $FadeSpots 1 sub {
    360 $FadeSpots div mul $FadeStartAngle add
    dup cos $FadeRadius mul exch sin $FadeRadius mul
    n $FadeSpotRadius 0 360 a f
  } for 
%</Sketch>

%<Sketch PaintFogWave>
  $FogWaveThickness w
  $FogWaveLength neg $FogWaveDistance 2 div m
  $FogWaveLength neg $FogWaveRaiseLength add $FogWaveDistance 2 div $FogWaveRaiseHeight add $FogWaveRaiseLength neg $FogWaveDistance 2 div $FogWaveRaiseHeight add 0 $FogWaveDistance 2 div c 
  $FogWaveRaiseLength $FogWaveDistance 2 div $FogWaveRaiseHeight sub $FogWaveLength $FogWaveRaiseLength sub $FogWaveDistance 2 div $FogWaveRaiseHeight sub $FogWaveLength $FogWaveDistance 2 div c
  $FogWaveLength neg $FogWaveDistance 2 div neg m
  $FogWaveLength neg $FogWaveRaiseLength add $FogWaveDistance 2 div neg $FogWaveRaiseHeight add $FogWaveRaiseLength neg $FogWaveDistance 2 div neg $FogWaveRaiseHeight add 0 $FogWaveDistance 2 div neg c 
  $FogWaveRaiseLength $FogWaveDistance 2 div neg $FogWaveRaiseHeight sub $FogWaveLength $FogWaveRaiseLength sub $FogWaveDistance 2 div neg $FogWaveRaiseHeight sub $FogWaveLength $FogWaveDistance 2 div neg c
  k
%</Sketch>

%<Sketch HDoubleLine>
	4 dict begin
	/y1 xd /x1 xd /y0 xd /x0 xd
	x1 x0 gt {
		x0 $WrapCenterX lt x1 $WrapCenterX ge and x1 x0 sub $WrapWidth gt and {
			x0 y0 x1 $MapImageWidth sub y1 x0 $MapImageWidth add y0 x1 y1 true
		}{
			x0 y0 x1 y1 false
		} ifelse
	}{
		x1 $WrapCenterX lt x0 $WrapCenterX ge and x0 x1 sub $WrapWidth gt and {
			x0 y0 x1 $MapImageWidth add y1 x0 $MapImageWidth sub y0 x1 y1 true
		}{
			x0 y0 x1 y1 false
		} ifelse
	} ifelse
	end
%</Sketch>

%<Sketch VDoubleLine>
	4 dict begin
	/y1 xd /x1 xd /y0 xd /x0 xd
	y1 y0 gt {
		y0 $WrapCenterY lt y1 $WrapCenterY ge and y1 y0 sub $WrapHeight gt and {
			x0 y0 x1 y1 $MapImageHeight sub x0 y0 $MapImageHeight add x1 y1 true
		}{
			x0 y0 x1 y1 false
		} ifelse
	}{
		y1 $WrapCenterY lt y0 $WrapCenterY ge and y0 y1 sub $WrapHeight gt and {
			x0 y0 x1 y1 $MapImageHeight add x0 y0 $MapImageHeight sub x1 y1 true
		}{
			x0 y0 x1 y1 false
		} ifelse
	} ifelse
	end
%</Sketch>

%<Sketch HVDoubleLine>
	6 dict begin
	/y1 xd /x1 xd /y0 xd /x0 xd
	/hWrap x1 x0 gt {
		x0 $WrapCenterX lt x1 $WrapCenterX ge and {	x1 x0 sub $WrapWidth div }{ 0 } ifelse
	}{
		x1 $WrapCenterX lt x0 $WrapCenterX ge and {	x0 x1 sub $WrapWidth div }{ 0 } ifelse
	} ifelse def
	/vWrap y1 y0 gt {
		y0 $WrapCenterY lt y1 $WrapCenterY ge and {	y1 y0 sub $WrapHeight div }{ 0 } ifelse
	}{
		y1 $WrapCenterY lt y0 $WrapCenterY ge and {	y0 y1 sub $WrapHeight div }{ 0 } ifelse
	} ifelse def
	hWrap 1 gt vWrap 1 gt and {
		vWrap hWrap lt { /hWrap }{ /vWrap } ifelse 0 def
	} if
	hWrap 1 gt {
		x0 y0 x1 x0 gt {
			x1 $MapImageWidth sub y1 x0 $MapImageWidth add y0
		}{
			x1 $MapImageWidth add y1 x0 $MapImageWidth sub y0
		} ifelse x1 y1 true
	}{
		vWrap 1 gt {
			y1 y0 gt {
				x0 y0 x1 y1 $MapImageHeight sub x0 y0 $MapImageHeight add x1 y1 true
			}{
				x0 y0 x1 y1 $MapImageHeight add x0 y0 $MapImageHeight sub x1 y1 true
			} ifelse
		}{
			x0 y0 x1 y1 false
		} ifelse
	} ifelse
	end
%</Sketch>

%<Sketch HDoublePointToMidLine>
	4 dict begin
	/y2 xd /x2 xd /y1 xd /x1 xd
	x1 x2 add x2 x1 gt {
		x1 $WrapCenterX lt x2 $WrapCenterX ge and x2 x1 sub $WrapWidth gt and
	}{
		x2 $WrapCenterX lt x1 $WrapCenterX ge and x1 x2 sub $WrapWidth gt and
	} ifelse {
		$MapImageWidth 1 index $MapImageLeft 2 mul $MapImageWidth add gt { sub }{ add } ifelse
	} if 2 div y1 y2 add 2 div $HDoubleLine
	end
%</Sketch>

%<Sketch VDoublePointToMidLine>
	4 dict begin
	/y2 xd /x2 xd /y1 xd /x1 xd
	x1 x2 add 2 div y1 y2 add y2 y1 gt { 
		y1 $WrapCenterY lt y2 $WrapCenterY ge and y2 y1 sub $WrapHeight gt and
	}{
		y2 $WrapCenterY lt y1 $WrapCenterY ge and y1 y2 sub $WrapHeight gt and
	} ifelse {
		$MapImageHeight 1 index $MapImageBottom 2 mul $MapImageHeight add gt { sub }{ add } ifelse
	} if 2 div $VDoubleLine
	end
%</Sketch>

%<Sketch HVDoublePointToMidLine>
	6 dict begin
	/y2 xd /x2 xd /y1 xd /x1 xd
	/hWrap x2 x1 gt { 
		x1 $WrapCenterX lt x2 $WrapCenterX ge and {	x2 x1 sub $WrapWidth div }{ 0 } ifelse 
	}{ 
		x2 $WrapCenterX lt x1 $WrapCenterX ge and {	x1 x2 sub $WrapWidth div }{ 0 } ifelse 
	} ifelse def
	/vWrap y2 y1 gt { 
		y1 $WrapCenterY lt y2 $WrapCenterY ge and {	y2 y1 sub $WrapHeight div }{ 0 } ifelse 
	}{ 
		y2 $WrapCenterY lt y1 $WrapCenterY ge and {	y1 y2 sub $WrapHeight div }{ 0 } ifelse
	} ifelse def
	hWrap 1 gt vWrap 1 gt and {
		vWrap hWrap lt { /hWrap }{ /vWrap } ifelse 0 def
	} if
	x1 x2 add hWrap 1 gt {
		$MapImageWidth 1 index $MapImageLeft 2 mul $MapImageWidth add gt { sub }{ add } ifelse
	} if 2 div y1 y2 add vWrap 1 gt {
		$MapImageHeight 1 index $MapImageBottom 2 mul $MapImageHeight add gt { sub }{ add } ifelse
	} if 2 div $HVDoubleLine
	end
%</Sketch>

%<Act OkOrder>
  [] 0 d
%</Act>

%<Act FailedOrder>
  [4 6] 2 d
%</Act>

%<Sketch DrawBoxFrameBorder>
  $Left# $Bottom# $Width# $Height# rectstroke
%</Sketch>

%<Sketch DrawInitialBoxFrameBorder>
  [4 6] 2 d
  $InitLeft# $InitBottom# $InitWidth# $InitHeight# rectstroke
  [] 0 d
%</Sketch>

%<Sketch TextColumnDefinitions>
%%IncludeResource: font Courier
/TextFixedFont /Courier $FindFont def
%</Sketch>

%<Sketch TextHeadingDefinitions>
%%IncludeResource: font Courier-Bold
/TextHeadingFont /Courier-Bold $FindFont def
%</Sketch>

%<Sketch TextTitleDefinitions>
%%IncludeResource: font Times-Roman
/TextTitleFont /Times-Roman $FindFont def
%</Sketch>

%<Sketch WriteTitle>
  $Left# $BaseX# add $Bottom# $BaseY# add m $ShowTitle
%</Sketch>

%<Sketch FitTitle>
  dup $Stringwidth pop dup $Width# gt {
    $Left# $Bottom# m
    $Width# exch div dup 1 x exch
    $BaseX# $BaseY# rmoveto $ShowTitle
    1 exch div 1 x
  }{
    pop $Left# $BaseX# add $Bottom# $BaseY# add m $ShowTitle
  } ifelse
%</Sketch>

%<Sketch SimpleFontBBox>
  $Font dup /FontMatrix get
  exch /FontBBox get aload pop
  5 dict begin
  /ury xd /urx xd /lly xd /llx xd /m xd
  llx lly m transform
  urx ury m transform 
  end
%</Sketch>

%<Sketch SimpleFontWidth /$String (X)>
  s $Font z $String stringwidth r
%</Sketch>

%<Play IdentifyPowerName>
  dup length 0 gt {
    dup 0 get $SpaceChar ne {

      %<Part none/>
      
    } if
  } if
%</Play>

%<Play CascadePowerName>
  dup length 0 gt {
    dup 0 get $SpaceChar eq dup 3 1 roll {
      dup length 1 sub 1 exch getinterval
    } if

    %<Part none/>

    exch {
      dup length 1 add string dup 0 $SpaceChar put dup 1 4 3 roll putinterval
    } if
  } if
%</Play>

%<Play UnpackPowerName>
  1 index {
    3 2 roll dup 0 get $OpenBracketChar eq {
      dup dup length 1 sub get $CloseBracketChar eq {
        1 1 index length 2 sub getinterval

        %<Part none/>

        dup length 2 add string
        dup 0 $OpenBracketChar put dup dup length 1 sub $CloseBracketChar put
        dup 1 4 3 roll putinterval 
      } if
    } if 3 1 roll
  } if
%</Play>

%<Sketch IsolatePowerName>
  ( ) search { 
    exch pop true exch
    0 3 index { 
      $SpaceChar ne { exit } if 1 add
    } forall dup 4 index length eq { 
      pop 3 1 roll pop pop false 
    } {
      dup 0 eq { pop } {
        4 3 roll dup length 3 2 roll dup 3 1 roll sub getinterval 3 1 roll
      } ifelse
    } ifelse
  } { false exch } ifelse
%</Sketch>

%<Sketch IsolatePowerBaseName>
  ( ) search { 
    exch pop true exch
    $BaseNameLength 1 index length sub dup 0 gt { 
      3 2 roll dup length 3 2 roll dup 3 1 roll sub getinterval exch
    } {
      pop
    } ifelse
  } { false exch } ifelse
%</Sketch>

%<Sketch ReattachPowerName>
  exch {
    dup length dup 1 add 3 index length add string
    dup 0 5 4 roll putinterval
    dup 2 index $SpaceChar put
    dup 3 2 roll 1 add 4 3 roll putinterval
  } if
%</Sketch>

%<Sketch WidenPowerName>
  exch {
	dup length dup $NameLength lt { $NameLength } { dup } ifelse 1 add
	dup 4 index length add string
	3 2 roll 1 3 index 1 sub { 1 index exch $SpaceChar put } for
	dup 0 5 4 roll putinterval
	dup 3 2 roll 4 3 roll putinterval  
  } if
%</Sketch>

%<Sketch ReplacePowerName>
	dup cvn load exec Power $NameKey get dup length 0 gt { exch } if pop
%</Sketch>

%<Sketch SplitString>
  7 dict begin
  /nrChars xd
  /indentString xd
  /objectString xd
  /objectLast objectString length 1 sub def
  % Short string?
  objectLast nrChars lt {
    false objectString
  }{
    % Look for a suitable place to split.
    % First tracking backwards, if that doesn't work, look forward.
    /splitIndex -1 def
    nrChars -1 0 {
      objectString 1 index get $SpaceChar eq {
        /splitIndex xd exit
      } if pop
    } for splitIndex -1 eq {
      nrChars 1 add 1 objectLast {
        objectString 1 index get $SpaceChar eq {
          /splitIndex xd exit
        } if pop
      } for
    } if
    splitIndex -1 eq splitIndex objectLast eq or {
      false objectString
    }{
      % The first part.
      objectString 0 splitIndex getinterval
      % The second part.
      objectString splitIndex 1 add objectLast splitIndex sub getinterval
      % Add indentation if needed.
      indentString length 0 gt {
        dup length indentString length add string
        dup 0 indentString putinterval
        dup indentString length 4 3 roll putinterval
      } if
      % Add white space of the first part.
      /nonSpaceIndex objectLast 1 add def
      0 1 objectLast {
        objectString 1 index get $SpaceChar ne {
          /nonSpaceIndex xd exit
        } if pop
      } for
      nonSpaceIndex 0 gt nonSpaceIndex splitIndex lt and {
        dup length nonSpaceIndex add string
        dup 0 objectString 0 nonSpaceIndex getinterval putinterval
        dup nonSpaceIndex 4 3 roll putinterval
      } if
      exch true exch
    } ifelse
  } ifelse
  end
%</Sketch>

%<Sketch IterateSplitString>
  (  ) {
    Step {
      /StepIndex StepIndex 1 add def
      /Step Steps StepIndex get def
    } if { not { exit } if () } if
  } loop
%</Sketch>

%<Sketch TextColumnSteps>
  { /Count 0 def /Y $StartY# def false true } bind
  {
    Count $BoxLength ge { false true } {
      $LineLength $SplitString
      /Count Count 1 add def /Y Y $CellHeight# sub def
      $StartX# Y m $ShowText
      true false
    } ifelse
 } bind
%</Sketch>

%<Sketch TextLastColumnSteps>
  { /Count 0 def /Y $StartY# def false true } bind
  {
    Count $BoxLength 1 sub ge { false true } {
      $LineLength $SplitString
      /Count Count 1 add def /Y Y $CellHeight# sub def
      $StartX# Y m $ShowText
      true false
    } ifelse
  } bind
  {
    $LineLength $SplitString [ exch {
      $StartX# $StopY# m $ShowText
    } /exec load ] cvx /Finish xd
    true true
  } bind
  {
    /Count 1 def /Finish {
      $StartX# $StopY# m (... \() $ShowMoreText
      Count dup 1 add log iceiling string cvs $ShowMoreText
      ( more\)) $ShowMoreText
    } bd false true
  } bind
  { /Count Count 1 add def $LineLength $SplitString pop true false } bind
%</Sketch>

%<Sketch TextStraddleFirstColumnSteps>
  { /Overlaps $BoxLength array def /Count 0 def /Y $StartY# def false true } bind
  {
    Count $BoxLength 1 sub ge { false true } {
      $OverlapLength $SplitString
      dup length $LineLength sub Overlaps Count 3 2 roll put
      /Count Count 1 add def /Y Y $CellHeight# sub def
      $StartX# Y m $ShowText
      true false
    } ifelse
  } bind
  {
    $PriorOverlapLength $SplitString
    dup length $LineLength sub Overlaps Count 3 2 roll put
    $StartX# $StopY# m $ShowText
    true true
  } bind
%</Sketch>

%<Sketch TextStraddleColumnSteps>
  { /Count 0 def /Y $StartY# def false true } bind
  {
    Count $BoxLength 1 sub ge { false true } {
      Overlaps Count get dup 0 gt {
        $LineLength $TextGapLineLength add sub Overlaps Count 3 2 roll put
        /Y Y $CellHeight# sub def
        false
      } {
        pop $OverlapLength $SplitString
        dup length $LineLength sub Overlaps Count 3 2 roll put
        /Y Y $CellHeight# sub def
        $StartX# Y m $ShowText
        true
      } ifelse /Count Count 1 add def false
    } ifelse
  } bind
  {
    Overlaps Count get dup 0 gt {
      $LineLength $TextGapLineLength add sub Overlaps Count 3 2 roll put
      false
    } {
      pop $PriorOverlapLength $SplitString
      dup length $LineLength sub Overlaps Count 3 2 roll put
      $StartX# $StopY# m $ShowText
      true
    } ifelse true
  } bind
%</Sketch>

%<Sketch TextStraddleLastColumnSteps>
  { /Count 0 def /Y $StartY# def false true } bind
  {
    Count $BoxLength 1 sub ge { false true } {
      Overlaps Count get 0 gt { /Y Y $CellHeight# sub def false } {
        $LineLength $SplitString
        /Y Y $CellHeight# sub def
        $StartX# Y m $ShowText
        true
      } ifelse /Count Count 1 add def false
    } ifelse
  } bind
  {
    $LineLength $SplitString [ exch {
      $StartX# $StopY# m $ShowText
    } /exec load ] cvx /Finish xd
    true true
  } bind
  {
    /Count 1 def /Finish {
      $StartX# $StopY# m (... \() $ShowMoreText
      Count dup 1 add log iceiling string cvs $ShowMoreText
      ( more\)) $ShowMoreText
    } bd false true
  } bind
  { /Count Count 1 add def $LineLength $SplitString pop true false } bind
%</Sketch>

%<Sketch TextOverlapFirstColumnSteps>
  { /Overlaps $BoxLength array def /Count 0 def /Remaining $TotalBoxLength def /Y $StartY# def false true } bind
  {
    Count $BoxLength ge {
      /StepIndex StepIndex 3 add def false true 
    } {
      /Y Y $CellHeight# sub def
      $OverlapLength $SplitString
      dup length $LineLength sub dup Overlaps Count 3 2 roll put
      $CountOverlaps dup Remaining ge { pop false true } {
        /Remaining Remaining 3 2 roll sub def
	    /Count Count 1 add def
	    $StartX# Y m $ShowText
	    true false
	  } ifelse
    } ifelse
  } bind
  {
    [ exch {
      $StartX# Y m $ShowText
    } /exec load ] cvx /Finish xd
    true true
  } bind
  {
    /Count 1 def /Finish {
      $StartX# Y m (... \() $ShowMoreText
      Count dup 1 add log iceiling string cvs $ShowMoreText
      ( more\)) $ShowMoreText
    } bd false true
  } bind
  { /Count Count 1 add def $OverlapLength $SplitString pop true false } bind
%</Sketch>

%<Sketch TextOverlapColumnSteps>
  { /Count 0 def /Y $StartY# def false true } bind
  {
    Count $BoxLength ge { 
      /StepIndex StepIndex 3 add def false true 
    } {
      /Y Y $CellHeight# sub def
      Overlaps Count get dup 0 gt {
        $LineLength $TextGapLineLength add sub Overlaps Count 3 2 roll put
        /Count Count 1 add def
        false false
      } {
        pop $OverlapLength $SplitString
        dup length $LineLength sub dup Overlaps Count 3 2 roll put
        $CountOverlaps dup Remaining ge { pop false true } {
          /Remaining Remaining 3 2 roll sub def
          /Count Count 1 add def
          $StartX# Y m $ShowText
          true false
        } ifelse
      } ifelse
    } ifelse
  } bind
  {
    [ exch {
      $StartX# Y m $ShowText
    } /exec load ] cvx /Finish xd
    true true
  } bind
  {
    /Count 1 def /Finish {
      $StartX# Y m (... \() $ShowMoreText
      Count dup 1 add log iceiling string cvs $ShowMoreText
      ( more\)) $ShowMoreText
    } bd false true
  } bind
  { /Count Count 1 add def $OverlapLength $SplitString pop true false } bind
%</Sketch>

%<Sketch TextOverlapLastColumnSteps>
  { /Count 0 def /Y $StartY# def false true } bind
  {
    /Y Y $CellHeight# sub def
    Count $BoxLength 1 sub ge { false true } {
      Overlaps Count get 0 gt { 
        /Count Count 1 add def false false
      } {
        Remaining 1 le { false true } {
          /Remaining Remaining 1 sub def
          $LineLength $SplitString
          /Count Count 1 add def
          $StartX# Y m $ShowText
          true false
        } ifelse
      } ifelse
    } ifelse
  } bind
  {
    $LineLength $SplitString [ exch {
      $StartX# Y m $ShowText
    } /exec load ] cvx /Finish xd
    true true
  } bind
  {
    /Count 1 def /Finish {
      $StartX# Y m (... \() $ShowMoreText
      Count dup 1 add log iceiling string cvs $ShowMoreText
      ( more\)) $ShowMoreText
    } bd false true
  } bind
  { /Count Count 1 add def $LineLength $SplitString pop true false } bind
%</Sketch>

%<Play WriteBoxFrame>
%<+ /$LineLength {BoxWidth $FontSize $TextFixedFontWidth mul div ifloor} /$BoxLength {BoxHeight $FontSize div ifloor}>
%<+ /$First 0 /$Last {$BoxLength 1 sub} /$ColumnLength $LineLength>
%<+ /$StartX {BoxLeft $TextFixedFontLeft $FontSize mul sub} /$StartY {BoxBottom BoxHeight add $TextFixedFontTop $FontSize mul sub}>
  4 dict begin
  /BoxHeight xd /BoxWidth xd /BoxBottom xd /BoxLeft xd
  TextFixedFont $FontSize y z

%<Part none/>

  end
%</Play>

%<Sketch WriteBoxFrameBorder /$Zero <0> /$Space < >>
%<+ /$Write {currentpoint 3 2 roll h $NewLine}>
  $FirstLine
  $LineLength string 0 1 $LineLength 1 sub {
    1 index exch dup 1 add 10 mod $Zero add put
  } for dup $Write
  1 1 $LineLength 2 sub {
    1 index exch $Space put
  } for
  1 1 $BoxLength 2 sub {
    1 index 0 2 index 1 add 10 mod $Zero add put
    1 index $LineLength 1 sub 3 2 roll $LineLength add 10 mod $Zero add put
    dup $Write
  } for
  0 1 $LineLength 1 sub {
    1 index exch dup $BoxLength add 10 mod $Zero add put
  } for $Write
%</Sketch>

%<Sketch PaintBBoxFrame>
%<+ /$FrameOuterThickness $FrameThickness /$FrameInnerThickness {$FrameThickness 4 div}>
%<+ /$FrameOuterLeft {$FrameLeft $FrameOuterThickness 2 div sub} /$FrameOuterBottom {$FrameBottom $FrameOuterThickness 2 div sub}>
%<+ /$FrameOuterWidth {$FrameWidth $FrameOuterThickness add} /$FrameOuterHeight {$FrameHeight $FrameOuterThickness add}>
%<+ /$FrameInnerLeft {$FrameOuterLeft $FrameInnerThickness 2 div add} /$FrameInnerBottom {$FrameOuterBottom $FrameInnerThickness 2 div add}>
%<+ /$FrameInnerWidth {$FrameOuterWidth $FrameInnerThickness sub} /$FrameInnerHeight {$FrameOuterHeight $FrameInnerThickness sub}>
	$FrameOuterColor $FrameOuterThickness# w
	$FrameOuterLeft# $FrameOuterBottom# $FrameOuterWidth# $FrameOuterHeight# rectstroke 
	$FrameInnerColor $FrameInnerThickness# w
	$FrameInnerLeft# $FrameInnerBottom# $FrameInnerWidth# $FrameInnerHeight# rectstroke 
%</Sketch>

%<Act PaintInnerHalfBorder /IsClipping 1 /IsHalfWidth -1>
	clip k
%</Act>

%<Act PaintOuterHalfBorder /IsClipping 1 /Executes 1 /IsHalfWidth 1>
	s strokepath pathbbox r
	2 copy m exch 3 index l 2 index 3 2 roll l l p 
	eoclip n exec p k
%</Act>

%<Sketch Border>
	$MapDrawingScale w [] 0 d $BorderStrokeColor
%</Sketch>

%<Sketch CoastalBorder>
	$MapDrawingScale w [] 0 d $BorderStrokeColor
%</Sketch>

%<Sketch InternalBorder>
	$MapDrawingScale w [6 $MapDrawingScale mul 2 $MapDrawingScale mul] 3 $MapDrawingScale mul d $BorderStrokeColor
%</Sketch>

%<Sketch NationalBorder>
	2 $MapDrawingScale mul w [] 0 d $BorderStrokeColor
%</Sketch>

%<Sketch MapNumberDefinitions>
%%IncludeResource: font Helvetica
/MapNumberFont /Helvetica $FindFont $MapNumberSize y def
%</Sketch>

%<Sketch PrintNumber>
  n
  $MaxNumberLength string cvs dup 4 1 roll 0 0 m true charpath pathbbox n
  3 -1 roll add 2 div 3 1 roll add 2 div exch
  3 -1 roll sub neg 3 1 roll sub exch m h
%</Sketch>

%</Play>

%%EndSetup
